import { Component } from '@angular/core';
import { Platform, NavController, AlertController } from 'ionic-angular';
import underscore from 'underscore/underscore';

import { LogPage } from '../log/log';//日志添加页
import { supervisionlogApi } from '../../providers/supervisionlog';
import { PubApi } from '../../providers/pubapi';
import { AppConfig } from '../../app/app.config';


@Component({
    selector: 'page-supervisionLog',
    templateUrl: 'supervisionLog.html'
})


export class SupervisionLogPage {
    public logdata: any;
    public img = []; //存放所有图片
    public num = null; //图片有没有缓存完
    constructor(public platform: Platform, public navCtrl: NavController, public auperapi: supervisionlogApi, public pubapi: PubApi) {

        platform.ready().then(() => {
            ///WorkLog/Query
            // this.auperapi.querylog().subscribe((res) => {
            //     debugger;
            //     this.logdata=res.data;
            //    // Situation



            // })



        });

    }


    ionViewDidEnter() {

        var that = this;
        this.pubapi.get("/WorkLog/Query", function (res) {
            var restotal = res;
            var num = 0;
            underscore.each(res.data, (itemt, indext) => {
                underscore.each(res.data[indext].imageId, (item, index) => {
                    that.img.push(AppConfig.imgUrl() + item);
                })
                num = num + 1;
                if (restotal.data.length == num) {
                    that.num = 666;
                }
                if (res.data[indext].imageId) {
                    res.data[indext].imageId = that.img;
                }
                that.img = [];

            })
            that.logdata = res.data;

        })


        // if ((<any>window).openid) {
        //     this.pubapi.get("feedback/openid?openid="+(<any>window).openid,function(res){
        //         var restotal = res;
        //         var num = 0;
        //         underscore.each(res.data, (itemt, indext) => {
        //             underscore.each(res.data[indext].imgid, (item, index) => {
        //                 that.img.push(AppConfig.imgUrl() + item);
        //             })
        //             num = num + 1;
        //             if (restotal.data.length == num) {
        //                     that.num=666;
        //             }

        //             res.data[indext].imgid = that.img;
        //             that.img = [];

        //         })
        //         this.feedbacksWechat = res.data;




        //     })
        // }



    }
    addsuper() {
        this.navCtrl.push(LogPage, {

        });
    }

}

